package com.zmn.plat.services.impl.log;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.log.SysLog;
import com.zmn.plat.model.entity.log.SysLogQuery;
import com.zmn.plat.persistence.interfaces.log.SysLogDao;
import com.zmn.plat.services.interfaces.log.SysLogService;

/**
 * @author nowind
 * @since 2017/9/20 19:18
 */
@Service
public class SysLogServiceImpl implements SysLogService {

    @Resource
    private SysLogDao sysLogDao;

    @Override
    public SysLog findByKey(Integer logId) {
        return sysLogDao.findByKey(logId);
    }

    @Override
    public List<SysLog> listPageByQuery(SysLogQuery query) {
        Integer count = this.countByQuery(query);
        query.setTotalCount(count);
        return count == 0 ? new ArrayList<>(0) : sysLogDao.listPageByQuery(query);
    }

    @Override
    public Integer countByQuery(SysLogQuery query) {
        return sysLogDao.countByQuery(query);
    }

    @Override
    public Integer add(SysLog sysLog) {
        return sysLogDao.insert(sysLog);
    }
}
